import http from '../request'
import type {PictureQueryDTO, PictureReview, PictureUpdateDTO} from '@/types/dto/picture'
import type {PictureVO} from '@/types/vo/picture'
import type {PageVO} from '@/types/common'

export const pictureApi = {
    /** 图片列表 */
    list(params: PictureQueryDTO) {
        return http.get<PageVO<PictureVO>>('/picture', {params})
    },

    /** 图片详情 */
    getById(id: number) {
        return http.get<PictureVO>(`/picture/${id}`)
    },

    /** 上传图片 */
    upload(formData: FormData) {
        return http.post<PictureVO>('/picture', formData)
    },

    /** 更新图片 */
    update(id: number, payload: PictureUpdateDTO) {
        return http.put<PictureVO>(`/picture/${id}`, payload)
    },

    /** 删除图片 */
    delete(id: number) {
        return http.delete<void>(`/picture/${id}`)
    },

    /** 下载图片 */
    downloadUrl(id: number) {
        return `/api/picture/${id}/download`
    },

    /** 分享图片 */
    share(id: number) {
        return http.post<void>(`/picture/${id}/share`)
    },

    /** 审核图片（管理员）*/
    review(id: number, payload: PictureReview) {
        return http.patch<void>(`/picture/admin/${id}/review`, payload)
    },

    /** 审核图片（管理员，别名） */
    reviewPicture(id: number, payload: PictureReview) {
        return this.review(id, payload)
    },
}


